﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;

namespace WMS.Seven.BaseService
{
    public interface IBaseAppService<T, K> where T : class
    {
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">要添加的实体</param>
        /// <returns>返回添加后的实体</returns>
        Task<T> AddAsync(T entity);

        /// <summary>
        /// 查询实体列表
        /// </summary>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页容量</param>
        /// <param name="orderby">排序字段</param>
        /// <param name="detailEntity">是否返回详细信息</param>
        /// <param name="filter">查询条件</param>
        /// <returns>返回分页结果</returns>
        Task<PagedResult<T>> GetListAsync<M>(int pageIndex, int pageSize, string orderby, bool detailEntity, Expression<Func<M, bool>> filter);

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity">要删除的实体</param>
        /// <returns>返回删除是否成功</returns>
        Task<bool> DeleteAsync(K entity);
        Task<bool> DeleteAsync(T model);

        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">要更新的实体</param>
        /// <returns>返回更新后的实体</returns>
        Task<T> UpdateAsync(K entity);
        /// <summary>
        /// 唯一性验证
        /// </summary>
        /// <typeparam name="M"></typeparam>
        /// <param name="filter"></param>
        /// <returns></returns>
        Task<bool> HasOnly(string filter, string param);
    }
}
